package com.mystyle.le.weekproject.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.mystyle.le.weekproject.R;

import java.util.List;

/**
 * Created by le on 2016/10/12.
 */
public class SoftAdapter extends BaseAdapter {
    private List<String> list;
    private Context context;

    public SoftAdapter(List<String> list, Context context) {
        this.list = list;
        this.context = context;
    }

    @Override
    public int getCount() {
        return list==null?0:list.size();
    }

    @Override
    public Object getItem(int position) {
        return list.get(position);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        ViewHolder holder;
        if (convertView==null){
            convertView = LayoutInflater.from(context).inflate(R.layout.soft_text_layout,parent,false);
            holder = new ViewHolder();
            holder.softadapter_TV = (TextView) convertView.findViewById(R.id.softadapter_TV);
            convertView.setTag(holder);
        }else {
            holder = (ViewHolder) convertView.getTag();
        }
        String s = list.get(position);
        holder.softadapter_TV.setText(s);
        return convertView;
    }
    class ViewHolder{
        TextView softadapter_TV;
    }
}
